package com.suket.jnn;

import java.text.DecimalFormat;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class NodeSupport {

  static Logger logger = Logger.getLogger(NodeSupport.class);

  public static String infoWeights( Node node ) {
    String result = "";
    if ( node == null ) {
      logger.log(Level.WARN, "Failed to perform info weights "
          + ", found null node");
      return result;
    }
    DecimalFormat df = new DecimalFormat(".00000");
    List listWeights = node.getWeights();
    if ( listWeights == null ) {
      return result;
    }
    int idx = 0;
    Iterator iterWeights = listWeights.iterator();
    while ( iterWeights.hasNext() ) {
      Weight weight = (Weight) iterWeights.next();
      if ( !result.equals("") ) {
        result += " , ";
      }
      result += "w[" + ( idx++ ) + "]: " + df.format(weight.getW());
    }
    return result;
  }

}
